package group2assignone.ucm;

import group2assignone.ucm.administrator.UCAdminLogin;
import group2assignone.ucm.customer.LoginCustomerProxy;
import group2assignone.ucm.manager.UCManagerLogin;
import group2assignone.view.MainView;

/**
 * -This is not a true use case... it is a mini use case used to determine
 * which use case to call for logging in.<br>
 * Use Case: Select login use case<br>
 * Pre-Condition: Main UI<br>
 * Post-Condition: Appropriate use case is called<br>
 * 1. Systems gets the Login type from the view<br>
 * 2. System compares login type with 'administrator, manager and general'<br>
 * 3. System loads appropriate login use case<br>
 * @author group2
 */
public class UCChooseLogin implements UCController {

    private MainView view;
    private String type;

    /**
     * assigns the view
     * @param view
     */
    public UCChooseLogin(MainView view) {
        this.view = view;
    }

    /**
     *  Use Case to select the correct login use case
     */
    public void run() {
        //1. Systems gets the Login type from the view
        type = view.getType();
        //2. System compares login type with 'administrator, manager and general'
        if (type.equals("Administrator")) {
            //3. System loads appropriate login use case
            UCAdminLogin ucal = new UCAdminLogin(view);
            ucal.run();
        } else if (type.equals("Manager")) {
            //3. System loads appropriate login use case
            UCManagerLogin ucml = new UCManagerLogin(view);
            ucml.run();
        } else if (type.equals("General")) {
            //3. System loads appropriate login use case
            LoginCustomerProxy uccl = new LoginCustomerProxy(view);
            //UCCustomerLogin uccl = new UCCustomerLogin(view);
            uccl.run();
        }
    }
}
